const { makeExecutableSchema } = require('graphql-tools');
const resolvers = require('./resolvers');

const typeDefs = `
input ActionItemInput {
  actionItem: String!
  associatedSupplier: String!
  status: Status!
  dueDate: String!
  respPerson: String!  
}
type ActionItem {
  id: Int!
  actionItem: String!
  associatedSupplier: String!
  status: Status!
  dueDate: String!
  respPerson: String!  
}
type PagedActionItem {
  actionItems: [ActionItem]
  dataCount: Int!
  pageLength: Int!
  pageIndex: Int!
}
input ActionNoteInput {
  note: String!
  updateBy: String!
  createDate: String!  
}
type ActionNote {
  id: Int!
  note: String!
  updateBy: String!
  createDate: String!  
}
type PagedActionNote {
  actionNotes: [ActionNote]
  dataCount: Int!
  pageLength: Int!
  pageIndex: Int!
}
enum Status{
  Open
  Closed
}
type Query {
  getActionNotes(page: Int): PagedActionNote
  getActionNote(id: Int!): ActionNote
  getActionItems(page: Int): PagedActionItem
  getActionItem(id: Int!): ActionItem
}
type Mutation {
  updateActionItem(id: ID!, input: ActionItemInput): ActionItem
  addActionItem(input: ActionItemInput): ActionItem
  updateActionNote(id: ID!, input: ActionNoteInput): ActionNote
  addActionNote(input: ActionNoteInput): ActionNote
}
`;

module.exports = makeExecutableSchema({ typeDefs, resolvers });